package com.dayu.springbootcache.controller;

import com.dayu.springbootcache.entity.Employee;
import com.dayu.springbootcache.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;


    @GetMapping("/emp/{id}")
    public Employee getEmployeeById(@PathVariable("id") Integer id){
        return employeeService.getEmp(id);
    }

    @GetMapping("/emp")
    public Employee updateEmp(Employee employee){
        System.out.println("updateEmp"+employee);
        return employeeService.updateEmp(employee);
    }

    @GetMapping("/delete")
    public void deleteEmp(Integer id){
       System.out.println("deleteEmp");
       employeeService.deleteEmp(id);
    }
}
